using System.Text.Json.Serialization;
using Vin.Extension.Framework.Dto;
using Vin.Extension.Framework.Quartz.Entities;
using Vin.Tool.Core.JsonCategory.Converters;

namespace Vin.Extension.Framework.Quartz.Dto.Entities;

public record SysJobRecordDto : VinFrameworkBaseEntityDto
{
    /// <summary>
    /// 任务名称
    /// </summary>
    public string? JobName { get; set; }

    /// <summary>
    /// 任务分组
    /// </summary>
    public long? GroupId { get; set; }

    /// <summary>
    /// 执行时间
    /// </summary>
    public DateTime? ExecuteTime { get; set; }

    /// <summary>
    /// 消耗时间
    /// </summary>
    public long? CostTime { get; set; }

    /// <summary>
    /// 总循环次数
    /// </summary>
    public int? LoopCount { get; set; }

    /// <summary>
    /// 当前循环次数
    /// </summary>
    public int? CurrentLoopCount { get; set; }

    /// <summary>
    /// 程序集路径
    /// </summary>
    public string? AssemblyPath { get; set; }

    /// <summary>
    /// 执行的程序集名称
    /// </summary>
    public string? AssemblyName { get; set; }

    /// <summary>
    /// 执行的任务类名
    /// </summary>
    public string? ClassName { get; set; }

    /// <summary>
    /// 任务参数
    /// </summary>
    [JsonConverter(typeof(ObjectToJsonStringConverter<List<JobParams>>))]
    public List<JobParams>? Parameters { get; set; }

    /// <summary>
    /// 状态 0:运行 10:成功 20:失败
    /// </summary>
    [JsonConverter(typeof(EnumToStringConverter<JobRecordStatus>))]
    public JobRecordStatus? Status { get; set; }

    /// <summary>
    /// 异常信息
    /// </summary>
    public string? Exception { get; set; }
}